package com.auxgroup.hr.front.commons.exception;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * @tags 客户端类型异常
 * @author penghui
 * @createDate 2017年10月23日
 */
public class ClientException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	private String errorCode;
	private String errorMsg;
	private Object retData;

	/**
	 * 
	 */
	public ClientException() {
		super();
	}

	/**
	 * @param cause
	 */
	public ClientException(Throwable cause) {
		super(cause);
	}

	/**
	 * @param errorCode
	 * @param errorMsg
	 */
	public ClientException(String errorCode, String errorMsg, Throwable e) {
		super(e);
		this.errorCode = errorCode;
		this.errorMsg = errorMsg;
	}

	/**
	 * @param errorCode
	 * @param errorMsg
	 */
	public ClientException(String errorCode, String errorMsg) {
		super();
		this.errorCode = errorCode;
		this.errorMsg = errorMsg;
	}

	/**
	 * @param errorCode
	 * @param errorMsg
	 * @param retData
	 */
	public ClientException(String errorCode, String errorMsg, Object retData) {
		super();
		this.errorCode = errorCode;
		this.errorMsg = errorMsg;
		this.retData = retData;
	}

	/**
	 * @param errorCode
	 * @param errorMsg
	 * @param retData
	 * @param e
	 */
	public ClientException(String errorCode, String errorMsg, Object retData, Throwable e) {
		super(e);
		this.errorCode = errorCode;
		this.errorMsg = errorMsg;
		this.retData = retData;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public Object getRetData() {
		return retData;
	}

	@Override
	public String getMessage() {
		StringBuilder sb = new StringBuilder();
		sb.append("error Code:").append(errorCode).append(", ");
		sb.append("error Msg:").append(errorMsg).append(", ");
		sb.append("retData:").append(ToStringBuilder.reflectionToString(retData)).append(", ");
		sb.append("exception msg:").append(super.getMessage());
		return sb.toString();
	}

}
